package com.feng.modules.core.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.feng.modules.core.service.ICommonServcie;

@SuppressWarnings("unchecked")
public class CommonAction extends BaseAction {
    private String commonMybatisId;

    public void setCommonMybatisId(String commonMybatisId) {
	this.commonMybatisId = commonMybatisId;
    }

    private ICommonServcie commonServcie;

    public void setCommonServcie(ICommonServcie commonServcie) {
	this.commonServcie = commonServcie;
    }
    /**
     * 分页函数
     * @param  map需有参数:pagesize：每页最大显示数；page ：当前页
     * @return 响应带有两个属性的一个map   Rows：数据对象；count:总数
     */
    public void pageList() {
	try {
	    Map<String, Object> param = new HashMap<String, Object>();
	    param.putAll(this.getParametersToMap());
	    param.putAll(this.getSession());
	    Map reMap = commonServcie.getPageList(commonMybatisId, param);
	    this.outJson(reMap);
	} catch (Exception e) {
	    e.printStackTrace();
	}
    }
    public void list() {
	try {
	    Map<String, Object> param = new HashMap<String, Object>();
	    param.putAll(this.getParametersToMap());
	    param.putAll(this.getSession());
	    List reList = commonServcie.getList(commonMybatisId, param);
	    this.outJson(reList);
	} catch (Exception e) {
	    e.printStackTrace();
	}
    }
    public void listRows() {
	try {
	    Map<String, Object> param = new HashMap<String, Object>();
	    param.putAll(this.getParametersToMap());
	    param.putAll(this.getSession());
	    Map<String,Object> reList = commonServcie.getListRows(commonMybatisId, param);
	    this.outJson(reList);
	} catch (Exception e) {
	    e.printStackTrace();
	}
    }
}
